function [ angel] = CalculateAngelBetweenPixels( imageName,X,x )
%display image and get 2 mouse clicks
image = my_image_read(imageName,2);
imshow(image);
[x1 y1] = ginput(1);
[x2 y2] = ginput(1);

%get the projection matrix
P = CalculateCameraProjectionMatrix(X,x);

C = CalculateCenterFromProjectionMatrix(P);

invP = pinv(P);

%calculate a point on the ray from the world coordinate corespondant with
%p1 an d C
p = invP * [x1 y1 1]';
p1 = p(1:3,:)./p(4);

%calculate a point on the ray from the world coordinate corespondant with
%p2 an d C
p = invP * [x2 y2 1]';
p2 = p(1:3,:)./p(4);

%calculate 2 rays, from C via p1 and from C via p2
r1 =p1-C';
r2 = p2-C';

%calculate the angel between those 2 rays in radians
cosT = dot(r1,r2)/(norm(r1)*norm(r2));

angel = acos(cosT);

end

